package com.yonyou.lx.controller;

import com.yonyou.lx.service.LxExpenseCardService;
import com.yonyou.ucf.mdd.ext.base.BaseController;
import com.yonyou.ucf.mdd.ext.util.ResultMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * @author Stephen Liu
 * @create 2024-02-23
 * @PackageName:main.java.com.yonyou.lx.controller
 * @ClassName: LxExpenseCardController
 * @Description: TODO：
 * @Version 1.0
 */

@RestController
@RequestMapping("lxExpenseCard")
public class LxExpenseCardController extends BaseController {

    @Autowired
    public LxExpenseCardService expenseCardService;

    /**
     * 根据 项目 获取经费卡 和 占用
     *
     * @param params   请求参数
     * @param request  请求
     * @param response 响应
     */
    @PostMapping("/getExpenseCardByProject")
    public void getExpenseCardByProject(@RequestBody Map<String, Object> params, HttpServletRequest request, HttpServletResponse response) {
        try {
            Map<String, Object> res = expenseCardService.getExpenseCardByProject((String) params.get("project"), (String) params.get("orgId"));
            renderJson(response, ResultMessage.data(res));
        } catch (Exception e) {
            e.printStackTrace();
            renderJson(response, ResultMessage.error(e.getMessage()));
        }
    }
}
